package com.kkb.robotcustomerservice.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.robotcustomerservice.dao.KnowledgeBaseDao;
import com.kkb.robotcustomerservice.entities.KnowledgeBase;
import com.kkb.robotcustomerservice.util.User;
import com.kkb.robotcustomerservice.service.KnowledgeBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
    @Autowired
    KnowledgeBaseDao knowledgeBaseDao;

    @Override
    public KnowledgeBase getById(Integer id) {
        return knowledgeBaseDao.selectById(id);
    }

    @Override
    public PageInfo<KnowledgeBase> findPage(Integer page, Integer rows, User user) {
        return PageHelper.startPage(page, rows).doSelectPageInfo(() -> knowledgeBaseDao.selectByPage(user));
    }

    @Override
    public Integer deleteAll(String createUser, String createSort) {
        return knowledgeBaseDao.deleteAll(createUser,createSort);
    }

    @Override
    public Integer deleteById(Integer qId) {
        return knowledgeBaseDao.deleteById(qId);
    }

    @Override
    public int insertList(List<KnowledgeBase> list,User user) {
        return knowledgeBaseDao.insertList(list,user);
    }

    @Override
    public int updateById(KnowledgeBase knowledgeBase) {
        return knowledgeBaseDao.updateById(knowledgeBase);
    }

    @Override
    public Integer insertOne(KnowledgeBase knowledgeBase) {
        return knowledgeBaseDao.insert(knowledgeBase);
    }
}
